#ifndef ANALYSERVIEW_H
#define ANALYSERVIEW_H

#include "libs/extension/extensionview.h"
#include <QAbstractItemModel>

QT_BEGIN_NAMESPACE
class QListView;
class QSortFilterProxyModel;
class QStandardItemModel;
class QTableView;
QT_END_NAMESPACE

namespace yc {
struct Attention;
struct RecordInfo;
}

namespace Ui {
class AnalyserView;
}

class AnalyserView : public yc::ExtensionView
{
    Q_OBJECT
public:
    enum Columns {
        CHECK_STATE_COLUMN,
        NUMBER_COLUMN,
        START_TIME_COLUMN,
        DURATION_COLUMN,
        FILENAME_COLUMN
    };

    explicit AnalyserView(yc::Extension* extension, QWidget* parent = nullptr);

private:
    void initPresenterList();
    void addAttention(yc::Attention* attention);
    void addRecord(yc::RecordInfo* record);
    void onCurrentPresenterChanged(const QModelIndex& current, const QModelIndex& previous);
    void showRecordContextMenu(const QPoint& pos);
    void updateAllCheckState();
    void updateUiStatus();
    bool canDelete() const;
    void openCurrentRecord();
    void locateCurrentRecord();
    void deleteCurrentRecord();
    void deleteRecords();
    void loadMoreRecords();
    void openRecord(const QModelIndex& index);
    void updateAvatar(const QString& filename);

    Ui::AnalyserView* ui;
    QStandardItemModel* presenter_model_;
    QSortFilterProxyModel* filter_model_;
    QStandardItemModel* record_model_;
};

#endif // ANALYSERVIEW_H
